package com.guochuang.yunwang.promanager.serviceImpl;

import com.guochuang.yunwang.promanager.dao.ProjectDetailMapper;
import com.guochuang.yunwang.promanager.domain.date;
import com.guochuang.yunwang.promanager.domain.progress;
import com.guochuang.yunwang.promanager.domain.vo.ProjectDetailVO;
import com.guochuang.yunwang.promanager.domain.vo.ProjectTimeLineVO;
import com.guochuang.yunwang.promanager.domain.vo.project.*;
import com.guochuang.yunwang.promanager.service.ProjectDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectDetailServiceImpl implements ProjectDetailService {


    @Autowired
    private ProjectDetailMapper projectDetailMapper;


    @Override
    public ProjectDetailVO getProjectDetailInfo(Integer pid) {

        ProjectDetailVO rec = projectDetailMapper.findNorProjectInfo(pid);

        if(rec.getGid()!=null){
            String hoster = projectDetailMapper.findProjectManager(rec.getGid(), "项目主管");
            String manager = projectDetailMapper.findProjectManager(rec.getGid(), "项目经理");
            rec.setHoster(hoster);
            rec.setManager(manager);
        }

        // 获取项目阶段
        rec.setStage(projectDetailMapper.findProjectStage(pid));

        return rec;
    }

    @Override
    public TasksVO gettaks(Integer pid) {
        return projectDetailMapper.findtasks(pid);
    }

    @Override
    public RequirementsVO getRequirements(Integer pid) {
        return projectDetailMapper.findrequirement(pid);
    }

    @Override
    public FlawsVO getflaws(Integer pid) {
        return projectDetailMapper.getflaws(pid);
    }

    @Override
    public ActVO getact(Integer pid) {
        return projectDetailMapper.getact(pid);
    }

    @Override
    public List<ProjectTimeLineVO> getProjectTimeLineData(Integer pid) {
        return projectDetailMapper.findProjectTimeLineData(pid);
    }

    @Override
    public progress getProjectProgressinfo(Integer pid){
        return projectDetailMapper.findProjectProgress(pid);
    }

    @Override
    public date getProjectDateinfo(Integer id){
        return projectDetailMapper.findProjectDate(id);
    }

}
